/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: qian
 * Date: 2023-03-26
 * Time: 16:53
 */

public class test2 {
    public static final long count=100000000;
    public static void concurrey() throws InterruptedException {
        long begin=System.nanoTime();
        Thread t=new Thread(new Runnable() {
            @Override
            public void run() {
                int a=0;
                for (int i=0;i<count;i++){
                    a--;
                }
            }
        });
        t.start();

        int b=0;
        for(int i=0;i<count;i++){
            b--;
        }
        t.join();
        long end=System.nanoTime();
        double ms=(end-begin)*1.0/1000/1000;
        System.out.println(ms);
    }
    public static void serial(){
        long begin=System.nanoTime();
        int a=0;
        for (int i=0;i<count;i++){
            a--;
        }
        int b=0;
        for(int i=0;i<count;i++){
            b--;
        }
        long end=System.nanoTime();
        double ms=(end-begin)*1.0/1000/1000;
        System.out.println(ms);
    }

    public static void main(String[] args) throws InterruptedException {
        concurrey();
        serial();
    }

}
